home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / raytrace / pov / gen / xtal4pov / xtal4pov.doc < prev    next >
Text File  |  1994-09-23  |  11KB  |  213 lines

  1.  
  2.  
  3. XTAL4POV Ver. 2.0
  4.  
  5.  
  6. This program generates POVRay 2.x data files of three-dimensional objects 
  7. with crystallographic symmetry. There is absolutely no need of knowing
  8. anything about crystallography to use this program successfully and create
  9. perfect crystal shapes. But for those who _want_ to know about crystallo-
  10. graphy, the file INTRO.DOC contains some very basic information. The program
  11. was originally written for my personal use in teaching crystallography, but
  12. since I got access to the UseNet some months ago, I realized from the DKB
  13. mailing list and comp.graphics.raytracing that other people might as well be
  14. interested in this. So I changed the program messages from german to english,
  15. added some documentation, and released the whole package ( .exe, source,
  16. documentation, and data files) to the public domain. Feel free to do with it
  17. whatever you want, including generating data files for POVRay. But be warned:
  18. this program may contain bugs, and I would like to hear about these, though 
  19. I cannot guarantee I'll have the time to fix them.
  20.  
  21.         THIS PROGRAM IS FREE SOFTWARE AND COMES "AS IS" WITH ABSOLUTELY
  22.         NO WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY
  23.         OR FITNESS FOR A PARTICULAR PURPOSE. USE IT AT YOUR OWN RISC!
  24.  
  25. (O.K., I hope that's enough to get off the hook.) 
  26.  
  27. System requirements: Any PC-AT compatible should do.
  28.  
  29. The program was compiled with MS C 6.00.
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. Usage:
  37.  
  38.         xtal4pov <-┘
  39.  
  40. The program will show a list of the seven crystal systems and their
  41. associated 32 crystal class symbols, and ask for input of one of the symbols.
  42. Chose one, and type it in EXACTLY as shown in the list, then press <return>.
  43. Next, the program asks for input of the Miller indices hkl. Type in three
  44. integer numbers between -98 and 98 with blanks between them, and press 
  45. <return>. The program will show a list of the generated Miller indices
  46. (actually: crystal faces), the number of generated faces, and the scale 
  47. factor, and asks for a new set of indices. Type in a new set, or type
  48. "99 0 0 <return>" for quitting. Then the program informs you that the data
  49. have been written to the file "crystal.inc", and exits. BTW, with real
  50. crystals, h, k, and l are always small numbers, say, between -10 and 10,
  51. but this is just a rule of thumb, and nothing forbids the use of larger
  52. numbers. 
  53.  
  54. If you wish to generate a new data file, and want to keep the old one, be
  55. sure to rename it to something else, for it will else be overwritten without
  56. asking.
  57.  
  58. The resulting file "crystal.inc" contains a header (commented out), and one
  59. or more #declare'd intersections of planes. The identifiers of the declara-
  60. tions look a little bit odd, but contain unique information: they are com-
  61. posed of the crystal class symbol you typed in, an underscore character, and
  62. the initial Miller indices. Unfortunately, POVRay doesn't like minus signs
  63. in identifiers, so all minus signs you typed in are converted to underscores.
  64. The body of the declaration contains the number of planes you saw on the 
  65. screen in POVRay 2.0 format, with the "scale" value as distance. This scaling
  66. has the purpose to keep all objects at about the same size, in fact, make 
  67. them fit into the unit cube. This is done using a very rough method, so it
  68. may not always work very well. This file can be #include'd into a scene file
  69. without further work. 
  70.  
  71. That's all you _need_ to know.
  72.  
  73. But maybe you _want_ to know more? O.K., here we go. First, for those really
  74. interested, there is a file INTRO.DOC, which contains some hopefully useful
  75. information on the crystallographic background of the program. Don't be
  76. afraid, I kept it as basic as I could.
  77.  
  78. Then, why did I write this program? Well, actually I wanted to make a simple
  79. scene containing the five Platonic Solids as an overhead transparency for my
  80. annual course in Elementary Crystallography. I thought this was not a big
  81. deal, for the necessary objects were already there, in SHAPES2.INC. But soon 
  82. I realized that the shapes themselves were o.k., but the orientations with
  83. respect to the coordinate system were wrong from a crystallographer's point
  84. of view. Moreover, the method of generating the shapes by rotating planes
  85. over and over seemed far too complicated. There is an easier way to make
  86. crystals in POVRay.
  87.  
  88. In crystallography, we describe a plane using the so-called Miller indices
  89. (neither Mike nor Henry, but William), a triple of integer numbers. These
  90. are calculated as the reciprocal values of the axis intersections, i.e. we
  91. measure on each crystal axis the distance from the origin to where it is cut
  92. by the plane, take the reciprocals, and make these to integers by multiplying
  93. with an appropriate number. Of course, this number must be the same for all 
  94. three values. Due to the special properties of crystals, this works always 
  95. for crystals. Well, and where's the trick? In an orthogonal coordinate sys-
  96. tem, the Miller indices represent the direction vector of the normal to the 
  97. plane, and that's exactly how planes are described in POVRay! So, to make a 
  98. crystal shape in POVRay, one needs only to know the Miller indices of all 
  99. faces, assign an appropriate distance to them, and make an intersection of 
  100. planes with the Miller indices as direction vector. No rotations anymore, and 
  101. as we calculate the Miller indices relative to the axes, all shapes are 
  102. properly aligned. So this is what the program mainly does: For a given
  103. symmetry, represented by the crystal class symbol, it calculates the com-
  104. plete set of symmetry equivalent planes, the crystal form or crystal shape, 
  105. for a given starting Miller index triple.
  106.  
  107. This works fine for cubic, tetragonal and orthorhombic crystals, as these 
  108. have orthogonal coordinate systems. For crystal systems with one or more 
  109. angles being not equal to 90 degrees, the Miller indices no longer represent
  110. the plane normals, so one has to make a coordinate transformation. This is no 
  111. big deal, as long as one knows the ratios of the respective axes and the 
  112. angles between them. For the hexagonal and trigonal system, there's no pro-
  113. blem, the ratio is 1 and the angle is 120 degrees in all cases, but in the
  114. monoclinic and triclinic system, these values vary. So here I come to the
  115. point where I have to admit I've been a bit lazy. The coordinate transforma-
  116. tions for hexagonal and trigonal crystals are built in to the program, but
  117. for the other two systems, they aren't, because for this it would have been
  118. necessary to let the program ask for the axis ratios and the angles. But as
  119. I think one wants to have shapes with high symmetry in raytracing, I decided
  120. not to invest further work in this. Who wants to trace a monoclinic crystal?
  121. However, the generation of Miller indices works correctly in both cases, so 
  122. one could do the transformation by hand. Maybe one would do this for mono-
  123. clinic, but as in the triclinic system every crystal form is either a single
  124. plane or a parallel pair of planes, it's not worth the effort.
  125.  
  126. Now you know what's going on. But before I give you some hints what to do
  127. with the data files, there's something more to say. As a matter of fact,
  128. some of the data sets, or to be more precise, quite a lot, describe objects,
  129. which are infinite in one or even two directions, so you have to combine
  130. these with appropriate other forms to get finite objects. There are lots of
  131. possible combinations, and as I don't want to write a novel here, I recommend
  132. you play around and find out for yourself. BTW, in the cubic system, all
  133. forms are finite.
  134.  
  135. Well, and now some bad news. Perhaps you may already have wondered, why I
  136. emphasize the term "crystallographic" that strongly. The reason is, that
  137. crystallographic symmetry is only a small subset of all possible symmetries,
  138. and many other symmetries don't use integer Miller indices, so their incor-
  139. poration into the program would have required a major rewriting. Unfor-
  140. tunatly, just the two famous Platonic Solids Regular Dodecahedron and
  141. Icosahedron require non-integer, even irrational, indices, and thus cannot
  142. be generated by the program. Yes, you've heard right: These two shapes can
  143. never be the shapes of naturally grown proper crystals! But for your con-
  144. venience, I have included a file PLATON.INC, which contains all five shapes,
  145. the non-crystallographic ones being handcarved, in their proper relative 
  146. orientations.
  147.  
  148. Well, and now, what to do with the data. First, of course you can use them
  149. as you like, scale them, rotate them, and even change the distances of single
  150. planes. No one has anything against it. We aren't here to do serious science,
  151. but to create good-looking pictures. It's only, at the moment, I can't give
  152. you anything else but a tool for creating scientific data, because this 
  153. program has it's origin in a real crystallographic program for computing
  154. interfacial angles and the like.
  155.  
  156. But although you aren't bound to adhere to crystallography, maybe there are
  157. one or two people out there, who at least want to know how to treat the data
  158. in a crystallographically correct way. Here are some hints.
  159.  
  160. Never construct a crystal by using shapes from different crystal classes.
  161.  
  162. Cubic crystals must always be scaled evenly in all three directions.
  163.  
  164. Hexagonal, trigonal, and tetragonal crystals must be scaled evenly in x and 
  165. y, z can be chosen at will.
  166.  
  167. Orthorhombic, monoclinic, and triclinic crystals can be scaled in any way.
  168.  
  169. To avoid scaling problems, I recommend the following procedure for hexagonal,
  170. trigonal, tetragonal, and orthorhombic crystals: first, apply identical
  171. scalings to all shapes you want to use in a crystal, and then use even 
  172. scaling to put the shapes together the way you want.
  173.  
  174. Well, and now I have a problem. As the data for monoclinic crystals don't
  175. contain the angle, there is no simple way in POVRay to produce a correct
  176. monoclinic crystal. But anyway, we can use a workaround, and though it's
  177. not correct, no one will be able to notice it. First, scale all shapes you 
  178. want to combine by the same amount, preferrably using different values for 
  179. x,y,z. Then rotate all shapes, for which l (=z) is not zero, around the  
  180. y-axis by the desired angle. This will, of course, change the values of
  181. the Miller indices, and you are quite likely to produce non-integer indices,
  182. but as no one will ever measure the angles between the faces in your ray-
  183. traced image, you will be safe. For combining the shapes to a crystal, 
  184. scale them now evenly in all directions, and the result will look quite
  185. monoclinic.
  186.  
  187. And for triclinic crystals? Scale and rotate as you wish. The result will
  188. be triclinic whatever you do, though it's certainly not correct from a crys-
  189. tallographic point of view. But who cares?
  190.  
  191.  
  192. To do:
  193.  
  194. 1.  Correct handling of monoclinic and triclinic system, if there is demand.
  195.  
  196. 2.  Inclusion of non-crystallographic symmetry.
  197.  
  198. 3.  Some sort of wire-frame previewer. But this will surely be quite a bit 
  199.     of work, and I hope, the POVGUI project will take this over.
  200.  
  201.  
  202. I hope, this program, though limited, will be useful, and I would greatly
  203. appreciate your comments, bug reports, etc.
  204.  
  205.  
  206. E-mail: Kosten@kristall.xtal.rwth-aachen.de
  207.  
  208. Snail mail: Klaus Kosten
  209.             Am Ginsterberg 13
  210.             D-52477 Alsdorf
  211.             Germany
  212.  
  213.